<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        li {
            list-style: none;
        }

        div {
            position: relative;
            width: 1000px;
            height: 500px;
            margin: 100px auto;
            background-color: #000;
            overflow: hidden;
        }

        ul {
            position: relative;
            width: 300px;
            height: 200px;
            margin: 100px auto 0;
        }

        ul li {
            position: absolute;
            left: 0;
            top: 0;
            width: 300px;
            height: 200px;
        }

        img {
            width: 100%;
            height: 100%;
        }

        input {
            display: none;
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            width: 40px;
            height: 80px;
            font-size: 30px;
            text-align: center;
            line-height: 80px;
            background: transparent;
            color: pink;
            border: none;
            outline: none;
            cursor: pointer;
        }

        input[id="left"] {
            left: 0;
        }

        input[id="right"] {
            right: 0;
        }
    </style>
    <script src="js/common.js">
    </script>
</head>

<body>
    <div id="dv">
        <input type="button" value="<" id="left">
        <input type="button" value=">" id="right">
        <ul id="oul">
            <li><img src="image/mm.png" alt=""></li>
            <li><img src="image/default.jpg" alt=""></li>
            <li><img src="image/cangjingkong.jpg" alt=""></li>
            <li><img src="image/girl.jpg" alt=""></li>
            <li><img src="image/yg_5.jpg" alt=""></li>
        </ul>
    </div>
    <script>
        var flag = true;
        var left = document.getElementById('left');
        var right = document.getElementById('right');
        var oul = document.getElementById('oul');
        var odiv = document.getElementById("dv");
        var arr = [];
        for (var i = 0; i < oul.children.length; i++) {
            arr[i] = oul.children[i];
        }
        arr = [
            {
                "left": 0,
                "top": 30,
                "width": 400,
                "height": 300,
                "zIndex": 2,
                "opacity": 1
            },
            {
                "left": 200,
                "top": 0,
                "width": 300,
                "height": 200,
                "zIndex": 1,
                "opacity": 0.7
            },
            {
                "left": 150,
                "top": -30,
                "width": 200,
                "height": 100,
                "opacity": 0.5
            },
            {
                "left": -150,
                "top": -30,
                "width": 200,
                "height": 100,
                "opacity": 0.5
            },
            {
                "left": -200,
                "top": 0,
                "width": 300,
                "height": 200,
                "zIndex": 1,
                "opacity": 0.7
            }
        ];
        f1(oul, arr);
        right.onclick = function () {
            if (flag) {
                flag = false;
                arr.push(arr.shift());
                f1(oul, arr);
            }
        }
        left.onclick = function () {
            if (flag) {
                flag = false;
                arr.unshift(arr.pop());
                f1(oul, arr);
            }
        }
        odiv.onmouseover = function () {
            left.style.display = "block";
            right.style.display = "block";
        }
        odiv.onmouseout = function () {
            left.style.display = "none";
            right.style.display = "none";
        }
        function f1(element, arr) {
            for (var i = 0; i < element.children.length; i++) {
                move(element.children[i], arr[i], function(){
                    flag = true;
                });
            }
        }

    </script>
</body>

</html>